<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>告警收敛</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f8f9fa;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .container {
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            max-width: 600px;
            width: 100%;
        }

        h2 {
            color: #333;
            text-align: center;
        }

        label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
            color: #555;
            text-align: left;
        }

        input[type="file"], input[type="text"], input[type="number"] {
            margin: 5px 0 15px 0;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 4px;
            width: calc(100% - 22px); /* Adjust width considering padding and border */
        }

        .monitoring-item {
            margin-bottom: 20px;
            border: 1px solid #ddd;
            padding: 10px;
            border-radius: 4px;
            position: relative;
            background-color: #f1f1f1;
        }

        .monitoring-item .item-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .monitoring-item .item-header input[type="text"] {
            width: calc(100% - 50px);
            margin-right: 10px;
        }

        .monitoring-item .item-header button.remove-item {
            background: #dc3545;
            border: none;
            color: white;
            cursor: pointer;
            font-size: 16px;
            padding: 5px 10px;
            border-radius: 4px;
        }

        .monitoring-item .item-header button.remove-item:hover {
            background-color: #c82333;
        }

        input[type="submit"], button {
            background-color: #007bff;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            margin-top: 10px;
            display: inline-block;
        }

        input[type="submit"]:hover, button:hover {
            background-color: #0056b3;
        }

        .actions {
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="container">
        <h2>告警关联分析</h2>
        
        <form action="/alarm_association" method="post" enctype="multipart/form-data">
            <label for="host_file">选择报警项数据文件：</label>
            <input type="file" id="host_file" name="host_file"><br>

            <div id="monitoring-items">
                <div class="monitoring-item">
                    <div class="item-header">
                        <label for="item_name">监控项名：</label>
                        <button type="button" class="remove-item" onclick="removeMonitoringItem(this)">&#128465;</button>
                    </div>
                    <input type="text" name="item_name[]"><br>
                    <label for="alldata_file">全时间序列文件：</label>
                    <input type="file" name="alldata_file[]"><br>
                    <label for="alarm_data_file">报警前5分钟数据文件：</label>
                    <input type="file" name="alarm_data_file[]"><br>
                </div>
            </div>

            <div class="actions">
                <button type="button" onclick="addMonitoringItem()">添加监控项</button><br><br>
                <input type="submit" value="确认执行">
            </div>
        </form>
    </div>
    
    <script>
        function addMonitoringItem() {
            var div = document.createElement('div');
            div.className = 'monitoring-item';
            div.innerHTML = `
                <div class="item-header">
                    <label for="item_name">监控项名：</label>
                    <button type="button" class="remove-item" onclick="removeMonitoringItem(this)">&#128465;</button>
                </div>
                <input type="text" name="item_name[]"><br>
                <label for="alldata_file">全时间序列文件：</label>
                <input type="file" name="alldata_file[]"><br>
                <label for="alarm_data_file">报警前5分钟数据文件：</label>
                <input type="file" name="alarm_data_file[]"><br>
            `;
            document.getElementById('monitoring-items').appendChild(div);
        }

        function removeMonitoringItem(button) {
            button.parentElement.parentElement.remove();
        }
    </script>
</body>
</html>
